package com.atguigu.tingshu.user.api;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.service.VipServiceConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "VIP服务配置管理接口")
@RestController
@RequestMapping("api/user/vipServiceConfig")
@SuppressWarnings({"unchecked", "rawtypes"})
public class VipServiceConfigApiController {

	@Autowired
	private VipServiceConfigService vipServiceConfigService;
	/**
	 * 根据itemId获取VIP服务配置信息
	 * @param id
	 * @return
	 */
	@Operation(summary = "根据itemId获取VIP服务配置信息")
	@GetMapping("/getVipServiceConfig/{id}")
	public Result<VipServiceConfig> getVipServiceConfig(@PathVariable("id") Long id){
		//  调用服务层方法. select * from vip_service_config where id = ?
		VipServiceConfig vipServiceConfig = vipServiceConfigService.getById(id);
		//  返回数据
		return Result.ok(vipServiceConfig);
	}

	/**
	 * 获取vip服务配置信息
	 * @return
	 */
	@Operation(summary = "获取vip服务配置信息")
	@GetMapping("/findAll")
	public Result findAllVipServiceConfig() {
		//	vip_service_config select * from vip_service_config; vipServiceConfigMapper.selectList();
		List<VipServiceConfig> list = vipServiceConfigService.list();
		//	返回数据.
		return Result.ok(list);
	}
}

